import React from "react";
import { Button, Popconfirm, message } from "antd";
import "antd/dist/antd.css";
import axios from "axios";
import qs from "qs";
export default class DelAll extends React.Component {
  constructor(props) {
    super(props);
    this.confirm = this.confirm.bind(this);
    this.state = {
      delDataSource: props.delDataSource,
    };
  }
  /**点击确认删除 */
  confirm() {
    /**删除全部会议数据 */
    axios
      .post(
        "deletemeetingbyid.rst",
        qs.stringify({
          delArr: "-1",
        })
      )
      .then((res) => {
        let response = res.data;
        if (response.resultCode === 0) {
          /**删除全部表格数据 */
          this.state.delDataSource(-1);
          this.props.getDataSource();
          message.success("删除会议成功");
        } else {
          message.error("删除会议失败");
        }
      })
      .catch((error) => {
        // this.state.delDataSource(-1)
        message.error("删除会议失败");
      });
  }

  render() {
    return (
      <>
        <Popconfirm
          title="确认要删除全部数据吗？"
          onConfirm={this.confirm}
          okText="Yes"
          cancelText="No"
        >
          <Button type="primary" danger>
            删除全部
          </Button>
        </Popconfirm>
      </>
    );
  }
}
